<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>战神 | 管理后台</title>
    <meta content='width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no' name='viewport'>
    <!-- bootstrap 3.0.2 -->
    <link href="/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <!-- font Awesome -->
    <link href="/bootstrap/css/font-awesome.min.css" rel="stylesheet" type="text/css" />
    <!-- Ionicons -->
    <link href="/bootstrap/css/ionicons.min.css" rel="stylesheet" type="text/css" />
    <!-- Theme style -->
    <link href="/bootstrap/css/AdminLTE.css" rel="stylesheet" type="text/css" />

    <style>
        .checkedtr{
            background-color: antiquewhite;
        }
    </style>
    <!-- jQuery 2.0.2 -->
    <script src="/bootstrap/js/jquery.min.js"></script>
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
    <script src="https://oss.maxcdn.com/libs/respond.js/1.3.0/respond.min.js"></script>
    <![endif]-->
</head>
<body class="skin-blue">
<!-- header logo: style can be found in header.less -->
<header class="header">

</header>
<div class="wrapper row-offcanvas row-offcanvas-left">
    <!-- Left side column. contains the logo and sidebar -->

    <!-- Right side column. Contains the navbar and content of the page -->
    <aside class="">
        <!-- Content Header (Page header) -->

        <!-- Main content -->
        <section class="content">
            <!-- general form elements -->
            <div class="row">
                <div class="col-md-8">
                    <div class="box box-primary">
                        <div class="box-header">
                            <h3 class="box-title">所有用户</h3>
                            <div class="box-tools">
                                <form method="post">
                                    <div class="input-group">
                                        <input type="text" id="keyword_input" name="keyword" class="form-control input-sm pull-right" style="width: 150px;" value="${keyword!}" placeholder="Search"/>
                                        <input type="hidden" id="keyword_page_id" name="pageNo" value="">
                                        <input type="hidden" id="keyword_uid" name="uid" value="">
                                        <div class="input-group-btn">
                                            <button id="keyword_btn" class="btn btn-sm btn-default" type="submit"><i class="fa fa-search"></i></button>
                                        </div>
                                    </div>
                                </form>
                            </div>
                        </div><!-- /.box-header -->
                        <div class="box-body table-responsive no-padding">
                            <table class="table table-hover">
                                <tr>
                                    <th>ID</th>
                                    <th>用户名</th>
                                    <th>创建日期</th>
                                    <th>状态</th>
                                </tr>
                            <#list pager.content as user>
                                <tr class="user_list " data-uid="${user.userId}">
                                    <td>${user.userId}</td>
                                    <td>${user.nick}<small>(登陆名:${user.userName})</small></td>
                                    <td>${user.createTime?string("yyyy-MM-dd")}</td>
                                    <td><#if user.status==1>
                                        <span class="label label-success">正常</span>
                                    <#else >
                                        <span class="label label-danger">停用</span>
                                    </#if></td>
                                </tr>
                            </#list>

                            </table>
                        </div><!-- /.box-body -->
                        <div class="box-footer">
                            <ul class="pagination pagination-sm pull-right">
                            <#include "/common/page.ftl" />
                            </ul>
                        </div>
                    </div><!-- /.box -->
                </div>
                <div class="col-md-4">
                    <div class="box box-warning">
                        <div class="box-header">
                            <h3 class="box-title">角色列表</h3>
                        </div><!-- /.box-header -->
                        <div class="box-body no-padding">
                            <table class="table table-condensed">
                                <tr>
                                    <th>角色名</th>
                                    <th>介绍</th>
                                </tr>
                                <#list urvlist as ur>
                                    <tr class="role_list <#if ur.userId??>checkedtr</#if>" data-rid="${ur.roleId}" data-uid="${uid!}">
                                        <td>${ur.roleName}</td>
                                        <td><small>${ur.roleComment}</small></td>
                                    </tr>
                                </#list>
                            </table>
                        </div><!-- /.box-body -->
                    </div><!-- /.box -->
                </div>
            </div>
        </section><!-- /.content -->
    </aside><!-- /. -->
</div><!-- ./wrapper -->



<!-- Bootstrap -->
<script src="/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<!-- AdminLTE App -->
<script src="/bootstrap/js/AdminLTE/app.js" type="text/javascript"></script>

<script>
    $('#keyword_input').change(function(){
        $('#keyword_page_id').val('');
        $('#keyword_uid').val('');
    });
    function repreList(page){
        $('#keyword_page_id').val(page);
        $('#keyword_uid').val('');
        $('#keyword_btn').click();
    }
    var uid='${uid!}';
    if(uid!=''){
        $('.user_list').each(function(){
            if(uid==$(this).attr('data-uid')){
                $(this).addClass("checkedtr");
            }
        });
    }

    $('.user_list').on('click',function(){
        $('.user_list').removeClass("checkedtr");
        $(this).addClass("checkedtr");
        var uid=$(this).attr('data-uid');
        //加载角色
        $('#keyword_uid').val(uid);
        $('#keyword_page_id').val(${pageNo});
        $('#keyword_btn').click();
    });

    $('.role_list').on('click',function(){
        var rid=$(this).attr('data-rid');
        var uid=$(this).attr('data-uid');
        if(uid!=''){
            $.post('obrole.json',{'uid':uid,'rid':rid},function(data){
                if(data.result=='success'){
                    window.location.reload();
                }
            });
        }
    });
</script>

</body>
</html>